# -*- coding:utf-8 -*-
# @FileName  :per_authorize.py
# @Time      :2020/11/27 9:50
# @Author    :Zhoujirong
# @Desc      :
import os
from common.http_request import Request
from biz.support.urls import ServerUrl
from conf.settings import PICTURES_DATA_PATH

class EntAuthorizeRequest:
    @classmethod
    def upload(cls,file,fileType,id,md5,needMd5,cookie):
        file = {
               'file': open(os.path.join(PICTURES_DATA_PATH, '%s') % file, 'rb')
           }
        data = {
            'fileType':fileType,
            'id':id,
            'md5':md5,
            'needMd5':needMd5,
        }
        req = Request(ServerUrl.ent_upload_url,data=data,files=file,headers=cookie)
        return req.post()

    @classmethod
    def find_archive(cls,archiveId,cookie):
        params = {
            'archiveId':archiveId
        }
        req = Request(ServerUrl.ent_archive_url,params=params,headers=cookie)
        return req.get_list()

    @classmethod
    def findbyid(cls, id, cookie):
        params = {
            'id': id
        }
        req = Request(ServerUrl.ent_findbyid_url, params=params, headers=cookie)
        return req.get()

    @classmethod
    def archive_update(cls,archiveType,enterpriseName,
                            creatTime,creator,signCode,
                            dsRegiNo,uniformSocialCredCode,
                            expireDate,ext1,
                            ext2,ext3,
                            ext4,ext5,
                            ext6,extendDate,
                            frgCorpNo,gsRegiNo,
                            id,note,
                            operTime,operationIdentifier,
                            operator,operOrg,orgCreditCode,
                            quantity,orgInstCode,
                            queryNum,remarks,ownOrg,
                            reqId,resCode,regiTypeCode,
                            resMsg,serialNumber,
                            startDate,status,
                            paperFileId,fileDescribe,cookie):
        data = {
                'archiveType':archiveType,
                'enterpriseName':enterpriseName,
                'signCode':signCode,
                'dsRegiNo':dsRegiNo,
                'uniformSocialCredCode':uniformSocialCredCode,
                'frgCorpNo':frgCorpNo,
                'gsRegiNo':gsRegiNo,
                'operOrg':operOrg,
                'orgCreditCode':orgCreditCode,
                'orgInstCode':orgInstCode,
                'ownOrg':ownOrg,
                'regiTypeCode':regiTypeCode,
                'creatTime':creatTime,
                'creator':creator,
                'expireDate':expireDate,
                'ext1':ext1,
                'ext2':ext2,
                'ext3':ext3,
                'ext4':ext4,
                'ext5':ext5,
                'ext6':ext6,
                'extendDate':extendDate,
                'id':id,
                'note':note,
                'operTime':operTime,
                'operationIdentifier':operationIdentifier,
                'operator':operator,
                'quantity':quantity,
                'queryNum':queryNum,
                'remarks':remarks,
                'reqId':reqId,
                'resCode':resCode,
                'resMsg':resMsg,
                'serialNumber':serialNumber,
                'startDate':startDate,
                'status':status,
                'paperFileId':paperFileId,
                'fileDescribe':fileDescribe
        }
        req = Request(ServerUrl.ent_archive_update_url,data=data,headers=cookie)
        return req.post()
    @classmethod
    def archive_del(cls,id,cookie):
        params={
            'id':id
        }
        req = Request(ServerUrl.ent_archive_del_url,params=params,headers=cookie)
        return req.post()
    @classmethod
    def archive_getpage(cls,curPage,
                            maxSize, search_EQ_enterpriseName,
                            search_EQ_signCode,search_EQ_uniformSocialCredCode,search_EQ_orgInstCode,
                            search_EQ_archiveType,search_EQ_creator,
                            search_IN_ownOrg,search_GTE_startDate_DATE,
                            search_LTE_expireDate_DATE,EQ_queryNum,cookie):
        params = {
            'curPage':curPage,
            'maxSize':maxSize,
            'search_EQ_enterpriseName':search_EQ_enterpriseName,
            'search_EQ_signCode':search_EQ_signCode,
            'search_EQ_uniformSocialCredCode':search_EQ_uniformSocialCredCode,
            'search_EQ_orgInstCode':search_EQ_orgInstCode,
            'search_EQ_archiveType':search_EQ_archiveType,
            'search_EQ_creator':search_EQ_creator,
            'search_IN_ownOrg':search_IN_ownOrg,
            'search_GTE_startDate_DATE':search_GTE_startDate_DATE,
            'search_LTE_expireDate_DATE':search_LTE_expireDate_DATE,
            'EQ_queryNum':EQ_queryNum
        }
        req = Request(ServerUrl.ent_archive_getpage_url,params=params,headers=cookie)
        return req.get()



if __name__ == "__main__":
    pass